﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace UpdateApp
{
    public partial class SimpleFiles : System.Web.UI.Page
    {
        protected string type;
        protected string date;
        protected string path;
        protected string temp = "";

        protected Dictionary<string, string> list = new Dictionary<string, string>();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {              
                date = Request["date"] != null ? Request["date"] : "";

                path = Path.Combine(FileHelper.GetDirName(), date);

                temp = FileHelper.GetTempDirName().Replace(FileHelper.GetDirName() + "/", "");

                if (Request["name"] != null)
                {
                    File.Delete(Path.Combine(FileHelper.GetUploadPath(), date, Request["name"]));

                    Response.Redirect(Request.Url.ToString().Replace("&name=" + Request["name"], ""));
                }

                string Check = ConfigurationManager.AppSettings["Check"];

                //只允许白名单中的IP下载
                if (Check == "1")                
                    if (!Common.CheckUserHost(HttpContext.Current))
                        return;
                
                list = FileHelper.GetFiles(date);
            }
        }
    }
}